home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / euro_fxd.h < prev    next >
C/C++ Source or Header  |  1996-03-07  |  21KB  |  810 lines

  1. //****************************************************************************
  2. //****************************************************************************
  3. //
  4. //
  5. // FIXED point class ... a replacement for floats in Actua Soccer
  6. //
  7. //    Format: Fixed (1,19,12)
  8. //
  9. //    NOTES :
  10. //        There is very little range checking at the moment so ...
  11. //
  12. //                                BE VERY CAREFUL
  13. //
  14. //    
  15. //
  16. //    Author : P.Rankin
  17. //    Version: 1.00.01.08.95
  18. //
  19. //****************************************************************************
  20. //****************************************************************************
  21.  
  22. #ifndef ABS
  23. #define ABS(a) (( (a) >= 0 ) ? (a):-(a))
  24. #endif
  25. #ifndef f2L
  26. #define f2L(f)    ((fixed)((long)((f)*4096)))
  27. #endif
  28.  
  29. #define ItoF(f) ((long) (f)*4096)
  30. #define FRACTION                12
  31. #define    HALF_FRACTION        6
  32.  
  33. extern "C" int  mul_64bit(int,int);
  34. extern "C" int  div_64bit(int,int);
  35.  
  36. class fixed {
  37. public:
  38.         long    f;
  39.         operator char();
  40.         operator unsigned char();
  41.         operator short();
  42.         operator    int();
  43.           operator    long();
  44.  
  45.         fixed();
  46.         fixed( int );
  47.         fixed( long );
  48.                 fixed( fixed const & );
  49.  
  50. //        fixed &operator = ( double );
  51.         fixed &operator = ( fixed const & );
  52. //        fixed &operator = ( float  );
  53.         fixed &operator = ( long   );
  54.         fixed &operator = ( int   );
  55.         fixed &operator = ( short    );
  56.  
  57.  
  58.         fixed &operator += ( fixed const & );
  59.         fixed &operator += ( long );
  60.         fixed &operator += ( int );
  61.         fixed &operator += ( short );
  62.         fixed &operator -= ( fixed const & );
  63.         fixed &operator -= ( long );
  64.         fixed &operator -= ( int );
  65.         fixed &operator -= ( short );
  66.         fixed &operator *= ( fixed const & );
  67.         fixed &operator *= ( long );
  68.         fixed &operator *= ( int );
  69.         fixed &operator *= ( short );
  70.         fixed &operator /= ( fixed const & );
  71.         fixed &operator /= ( int );
  72.         fixed &operator /= ( short );
  73.         fixed &operator >>= ( int );
  74.         fixed &operator <<= ( int );
  75.  
  76.         fixed operator + () const;
  77.         fixed operator - () const;
  78.  
  79. };
  80.  
  81. fixed operator * ( fixed const &, fixed const &);
  82. fixed operator * ( fixed const &, int);
  83. fixed operator * ( fixed const &, short);
  84. fixed operator * ( fixed const &, long);
  85. fixed operator * ( int   , fixed const & );
  86. fixed operator * ( short , fixed const & );
  87. fixed operator * ( long , fixed const &);
  88.  
  89. fixed operator + ( fixed const &, fixed const &);
  90. fixed operator + ( fixed const &, long);
  91. fixed operator + ( fixed const &, int);
  92. fixed operator + ( fixed const &, short);
  93. fixed operator + ( long __f1 , fixed const &__f0 );
  94. fixed operator + ( int , fixed const & );
  95. fixed operator + ( short , fixed const & );
  96.  
  97.  
  98. fixed operator - ( fixed const &, fixed const &);
  99. fixed operator - ( fixed const &, long);
  100. fixed operator - ( fixed const &, int);
  101. fixed operator - ( fixed const &, short);
  102. fixed operator - ( long   ,fixed const &);
  103. fixed operator - ( int   ,fixed const &);
  104. //fixed operator - ( short ,fixed const &);
  105.  
  106.  
  107. fixed operator / ( fixed const &, fixed const &);
  108. fixed operator / ( fixed const &, long);
  109. fixed operator / ( fixed const &, int);
  110. fixed operator / ( fixed const &, short);
  111. fixed operator / ( long , fixed const & );
  112. fixed operator / ( int , fixed const & );
  113.  
  114. int operator == ( fixed const &, fixed const & );
  115. int operator == ( fixed const &, int );
  116. int operator == ( fixed const &, short );
  117. int operator == ( int ,fixed const & );
  118. int operator == ( short  ,fixed const & );
  119.  
  120. int operator != ( fixed const &, fixed const & );
  121. int operator != ( fixed const &, int );
  122. int operator != ( fixed const &, short );
  123. int operator != ( int ,fixed const & );
  124. int operator != ( short  ,fixed const & );
  125.  
  126. int operator < ( fixed const &, fixed const & );
  127. int operator < ( fixed const &, long );
  128. int operator < ( fixed const &, int );
  129. int operator < ( fixed const &, short );
  130. int operator < ( long , fixed const & );
  131. int operator < ( int ,fixed const & );
  132. int operator < ( short  ,fixed const & );
  133.  
  134. int operator > ( fixed const &, fixed const & );
  135. int operator > ( fixed const &, long );
  136. int operator > ( fixed const &, int );
  137. int operator > ( fixed const &, short );
  138. int operator > ( long , fixed const & );
  139. int operator > ( int ,fixed const & );
  140. int operator > ( short  ,fixed const & );
  141.  
  142. int operator <= ( fixed const &, fixed const & );
  143. int operator <= ( fixed const &, long );
  144. int operator <= ( fixed const &, int );
  145. int operator <= ( fixed const &, short );
  146. int operator <= ( int ,fixed const & );
  147. int operator <= ( short  ,fixed const & );
  148.  
  149. int operator >= ( fixed const &, fixed const & );
  150. int operator >= ( fixed const &, long );
  151. int operator >= ( fixed const &, int );
  152. int operator >= ( fixed const &, short );
  153. int operator >= ( int ,fixed const & );
  154. int operator >= ( short  ,fixed const & );
  155.  
  156.  
  157.  
  158.  
  159. //****************************************************************************
  160. //
  161. //    Constructors
  162. //
  163. //****************************************************************************
  164.  
  165. inline fixed::fixed() {
  166. }
  167.  
  168. inline fixed::fixed( int __f0 ) {
  169.         f = __f0 << FRACTION;
  170. }
  171.  
  172. inline fixed::fixed( long __f0 ) {
  173.         f = __f0 ;
  174. }
  175.  
  176. inline fixed::fixed( fixed const &__f0 ) {
  177.         f = __f0.f;
  178. }
  179.  
  180.  
  181. //****************************************************************************
  182. //
  183. //    Casts
  184. //
  185. //****************************************************************************
  186.  
  187. inline fixed:: operator char() {
  188.     return( f>>FRACTION );
  189. }
  190.  
  191. inline fixed:: operator unsigned char() {
  192.     return( f>>FRACTION );
  193. }
  194. inline fixed:: operator short() {
  195.     return( f>>FRACTION );
  196. }
  197.  
  198. inline fixed:: operator int() {
  199.     return( f>>FRACTION );
  200. }
  201.  
  202. inline fixed:: operator long() {
  203.     return( f );
  204. }
  205.  
  206. //****************************************************************************
  207. //
  208. //    =
  209. //
  210. //****************************************************************************
  211.  
  212. inline fixed &fixed:: operator =(fixed const &__d) {
  213.         f = (long) ( __d.f );
  214.             return(*this);
  215. }
  216.  
  217. inline fixed &fixed:: operator =(int __d) {
  218.         f = ( ItoF(__d) );
  219.             return(*this);
  220. }
  221.  
  222. inline fixed &fixed:: operator =(long __d) {
  223.         f = ( (__d) );
  224.             return(*this);
  225. }
  226.  
  227.  
  228. inline fixed &fixed:: operator =(short __d) {
  229.         f = ( ItoF(__d) );
  230.             return(*this);
  231. }
  232.  
  233. //****************************************************************************
  234. //
  235. //    *
  236. //
  237. //****************************************************************************
  238.  
  239. inline fixed operator * ( fixed const &__f0, fixed const &__f1 ) {
  240.     return((long)mul_64bit(__f0.f,__f1.f));
  241. }
  242.  
  243. inline fixed operator * ( fixed const &__f0, long __f1 ) {
  244.     return((long)mul_64bit(__f0.f,__f1));
  245. }
  246.  
  247. inline fixed operator * ( fixed const &__f0, int __f1 ) {
  248.     return( ((long)(__f0.f)) * __f1 );
  249. }
  250.  
  251. inline fixed operator * ( fixed const &__f0, short __f1 ) {
  252.     return( ((long)(__f0.f)) * __f1 );
  253. }
  254.  
  255. inline fixed operator * (  int __f1 , fixed const &__f0) {
  256.     return( ((long)(__f0.f)) * __f1 );
  257. }
  258.  
  259. inline fixed operator * (  short __f1 , fixed const &__f0) {
  260.     return( ((long)(__f0.f)) * __f1 );
  261. }
  262.  
  263. inline fixed operator * (  long __f1  , fixed const &__f0) {
  264.     return((long)mul_64bit(__f1,__f0.f));
  265. }
  266.  
  267. //****************************************************************************
  268. //
  269. //    +
  270. //
  271. //****************************************************************************
  272.  
  273. inline fixed operator + ( fixed const &__f0, fixed const &__f1 ) {
  274.     return( __f0.f + __f1.f );
  275. }
  276.  
  277. inline fixed operator + ( fixed const &__f0, long __f1 ) {
  278.     return( __f0.f + ((long)__f1) );
  279. }
  280.  
  281. inline fixed operator + ( fixed const &__f0, int __f1 ) {
  282.     return( __f0.f + (((long)__f1)<<FRACTION) );
  283. }
  284.  
  285. inline fixed operator + ( fixed const &__f0, short __f1 ) {
  286.     return( __f0.f + (((long)__f1)<<FRACTION) );
  287. }
  288.  
  289. inline fixed operator + ( long __f1 , fixed const &__f0 ) {
  290.     return( __f0.f + ((long)__f1) );
  291. }
  292.  
  293. inline fixed operator + ( int __f1 , fixed const &__f0 ) {
  294.     return( __f0.f + (((long)__f1)<<FRACTION) );
  295. }
  296.  
  297. inline fixed operator + ( short __f1 , fixed const &__f0 ) {
  298.     return( __f0.f + (((long)__f1)<<FRACTION) );
  299. }
  300.  
  301. //****************************************************************************
  302. //
  303. //    -
  304. //
  305. //****************************************************************************
  306.  
  307. inline fixed operator - ( fixed const &__f0, fixed const &__f1 ) {
  308.     return( __f0.f - __f1.f );
  309. }
  310.  
  311. inline fixed operator - ( fixed const &__f0, long __f1 ) {
  312.     return( __f0.f - (((long)__f1)) );
  313. }
  314.  
  315. inline fixed operator - ( fixed const &__f0, int __f1 ) {
  316.     return( __f0.f - (((long)__f1)<<FRACTION) );
  317. }
  318.  
  319. inline fixed operator - ( fixed const &__f0, short __f1 ) {
  320.     return( __f0.f - (((long)__f1)<<FRACTION) );
  321. }
  322.  
  323. inline fixed operator - ( long __f1 , fixed const &__f0 ) {
  324.     return( ( (((long)__f1)) - __f0.f ) );
  325. }
  326.  
  327. inline fixed operator - ( int __f1 , fixed const &__f0 ) {
  328.     return( ( (((long)__f1)<<FRACTION) - __f0.f ) );
  329. }
  330.  
  331. /*
  332. inline fixed operator - ( short __f1 , fixed const &__f0 ) {
  333.     return( (((long)__f1)<<FRACTION) - __f0.f ) );
  334. }
  335. */
  336.  
  337. //****************************************************************************
  338. //
  339. //    /
  340. //
  341. //****************************************************************************
  342.  
  343. inline fixed operator / ( fixed const &__f0, fixed const &__f1 ) {
  344.     if(__f1.f!=0)
  345.         return((long)div_64bit(__f0.f,__f1.f));
  346.     else
  347.         return(__f0);
  348.  
  349. #if    0
  350.     if(( __f0.f <= 0x3ffff )&&(__f0.f >= -0x3ffff))
  351.         {
  352.         if(__f1.f!=0)
  353.             return ( ( (__f0.f << FRACTION) / __f1.f ) );
  354.         else
  355.             return ( __f0.f );
  356.         }
  357.     else            
  358.         {
  359.         if(ABS(__f1.f) < (long)64 )
  360.             return ( __f0.f );
  361.         else
  362.             return ( ( __f0.f / (__f1.f>>HALF_FRACTION) ) <<HALF_FRACTION );
  363.         }
  364. #endif
  365. }
  366.  
  367. inline fixed operator / ( fixed const &__f0, long __f1 ) {
  368.     if(( __f0.f < 0x3ffff )&&(__f0.f > -0x3ffff))
  369.         return ( ( (__f0.f << FRACTION) / __f1 ) );
  370.     else
  371.         return ( ( __f0.f / (__f1>>HALF_FRACTION) ) <<HALF_FRACTION );
  372. }
  373.  
  374. inline fixed operator / ( fixed const &__f0, int __f1 ) {
  375.         return ( ( __f0.f / __f1 ) );
  376. }
  377.  
  378. inline fixed operator / ( fixed const &__f0, short __f1 ) {
  379.         return ( ( __f0.f / __f1 ) );
  380. }
  381.  
  382. inline fixed operator / ( long __f0 , fixed const &__f1 ) {
  383.     if(__f1.f!=0)
  384.         return((long)div_64bit(__f0,__f1.f));
  385.     else
  386.         return(__f0);
  387.  
  388. #if    0
  389.     if(( __f0 < 0x3ffff )&&(__f0 > -0x3ffff))
  390.         return ( ( (__f0 << FRACTION) / __f1.f ) );
  391.     else
  392.         return ( ( __f0 / (__f1.f>>HALF_FRACTION) ) <<HALF_FRACTION );
  393. #endif
  394. }
  395.  
  396. inline fixed operator / ( int __f0 , fixed const &__f1 ) {
  397.     if(__f1.f!=0)
  398.         return((long)div_64bit(__f0 << FRACTION,__f1.f));
  399.     else
  400.         return(__f0);
  401.  
  402. #if    0
  403.     if(( __f0 <= 0x7f )&&(__f0 >= -0x7f))
  404.         {
  405.         if( __f1.f != 0 )
  406.             return ( ( (__f0 << (2*FRACTION)) / __f1.f ) );
  407.         else
  408.             return ( __f0 );
  409.         }
  410.     else
  411.         {
  412.         if(ABS(__f1.f)< (long)64 )
  413.             return ( __f0 );
  414.         else
  415.             return ( ( (__f0 << FRACTION) / (__f1.f>>HALF_FRACTION) ) <<HALF_FRACTION );
  416.         }
  417. #endif
  418. }
  419.  
  420.  
  421. //****************************************************************************
  422. //
  423. //    +=
  424. //
  425. //****************************************************************************
  426.  
  427. inline fixed &fixed::operator += ( fixed const &__cv ) {
  428.     f += __cv.f;
  429.     return ( *this );
  430. }
  431.  
  432. inline fixed &fixed::operator += ( long __cv ) {
  433.     f += ( __cv );
  434.     return ( *this );
  435. }
  436.  
  437. inline fixed &fixed::operator += ( int __cv ) {
  438.     f += ( __cv<<FRACTION );
  439.     return ( *this );
  440. }
  441.  
  442. inline fixed &fixed::operator += ( short __cv ) {
  443.     f += ( __cv<<FRACTION );
  444.     return ( *this );
  445. }
  446.  
  447. //****************************************************************************
  448. //
  449. //    -=
  450. //
  451. //****************************************************************************
  452.  
  453. inline fixed &fixed::operator -= ( fixed const &__cv ) {
  454.     f -= __cv.f;
  455.     return ( *this );
  456. }
  457.  
  458. inline fixed &fixed::operator -= ( long __cv ) {
  459.     f += ( __cv );
  460.     return ( *this );
  461. }
  462.  
  463. inline fixed &fixed::operator -= ( int __cv ) {
  464.     f -= ( __cv<<FRACTION );
  465.     return ( *this );
  466. }
  467.  
  468. inline fixed &fixed::operator -= ( short __cv ) {
  469.     f -= ( __cv<<FRACTION );
  470.     return ( *this );
  471. }
  472.  
  473. //****************************************************************************
  474. //
  475. //    *=
  476. //
  477. //****************************************************************************
  478.  
  479.  
  480. inline fixed &fixed::operator *= ( fixed const &__cv ) {
  481.     f = (f >> HALF_FRACTION ) * (__cv.f >> HALF_FRACTION);
  482.     return ( *this );
  483. }
  484.  
  485. inline fixed &fixed::operator *= ( long __cv ) {
  486.     f = (f >> HALF_FRACTION ) * (__cv >> HALF_FRACTION);
  487.     return ( *this );
  488. }
  489. inline fixed &fixed::operator *= ( int __cv ) {
  490.     f *= ( __cv );
  491.     return ( *this );
  492. }
  493.  
  494. inline fixed &fixed::operator *= ( short __cv ) {
  495.     f *= ( __cv );
  496.     return ( *this );
  497. }
  498.  
  499.  
  500. //****************************************************************************
  501. //
  502. //    /=
  503. //
  504. //****************************************************************************
  505.  
  506.  
  507. inline fixed &fixed::operator /= ( fixed const &__cv ) {
  508.     if(ABS(__cv.f)<64)
  509.         return (*this);
  510.     else
  511.         f = ( ( f / (__cv.f>>HALF_FRACTION) ) <<HALF_FRACTION );
  512.     return( *this );
  513. }
  514.  
  515. inline fixed &fixed::operator /= ( int __cv ) {
  516.     if(f!=0)
  517.         f /= ( __cv );
  518.     return ( *this );
  519. }
  520.  
  521. inline fixed &fixed::operator /= ( short __cv ) {
  522.     if(f!=0)
  523.         f /= ( __cv );
  524.     return ( *this );
  525. }
  526.  
  527.  
  528. //****************************************************************************
  529. //
  530. //    << >> <<= >>=
  531. //
  532. //****************************************************************************
  533.  
  534. #if    0
  535. inline int operator << ( int __i ) {
  536. //        f = f << __i;
  537.         return ( f<<__i );
  538. }
  539. #endif
  540.  
  541. inline fixed &fixed::operator <<= ( int __i ) {
  542.     f <<= __i;
  543.     return ( *this );
  544. }
  545.  
  546. #if    0
  547. inline int operator >> ( int __i ) {
  548. //        f = f >> __i;
  549.         return (f >>__i );
  550. }
  551. #endif
  552.  
  553. inline fixed &fixed::operator >>= ( int __i ) {
  554.     f >>= __i;
  555.     return ( *this );
  556. }
  557.  
  558.  
  559.  
  560. inline fixed fixed::operator + () const {
  561.     return( *this );
  562. }
  563.  
  564. inline fixed fixed::operator - () const {
  565.     return( -f );
  566. }
  567.  
  568. //****************************************************************************
  569. //
  570. // Conditionals
  571. //
  572. //        ==
  573. //
  574. //****************************************************************************
  575.  
  576. inline int operator == ( fixed const &__f0, fixed const &__f1 ) {
  577.     return ( __f0.f == __f1.f );
  578. }
  579.  
  580. inline int operator == ( fixed const &__f0, int __f1 ) {
  581.         return ( __f0.f == (__f1<<FRACTION) );
  582. }
  583.  
  584. inline int operator == ( fixed const &__f0, short __f1 ) {
  585.         return ( __f0.f == (__f1<<FRACTION) );
  586. }
  587.  
  588. inline int operator == ( int __f1 , fixed const &__f0 ) {
  589.         return ( __f0.f == (__f1<<FRACTION) );
  590. }
  591.  
  592. inline int operator == ( short __f1 , fixed const &__f0 ) {
  593.         return ( __f0.f == (__f1<<FRACTION) );
  594. }
  595.  
  596.  
  597. //****************************************************************************
  598. //
  599. //    !=
  600. //
  601. //****************************************************************************
  602.  
  603. inline int operator != ( fixed const &__f0, fixed const &__f1 ) {
  604.     return ( __f0.f != __f1.f );
  605. }
  606.  
  607. inline int operator != ( fixed const &__f0, int __f1 ) {
  608.         return ( __f0.f != (__f1<<FRACTION) );
  609. }
  610.  
  611. inline int operator != ( fixed const &__f0, short __f1 ) {
  612.         return ( __f0.f != (__f1<<FRACTION) );
  613. }
  614.  
  615. inline int operator != ( int __f1 , fixed const &__f0 ) {
  616.         return ( __f0.f != (__f1<<FRACTION) );
  617. }
  618.  
  619. inline int operator != ( short __f1 , fixed const &__f0 ) {
  620.         return ( __f0.f != (__f1<<FRACTION) );
  621. }
  622.  
  623.  
  624. //****************************************************************************
  625. //
  626. //    <
  627. //
  628. //****************************************************************************
  629.  
  630. inline int operator < ( fixed const &__f0, fixed const &__f1 ) {
  631.     return ( __f0.f < __f1.f );
  632. }
  633.  
  634. inline int operator < ( fixed const &__f0, long __f1 ) {
  635.     return ( __f0.f < __f1 );
  636. }
  637.  
  638. inline int operator < ( fixed const &__f0, int __f1 ) {
  639.     return ( (__f0.f) < (__f1<<FRACTION) );
  640. }
  641.  
  642. inline int operator < ( fixed const &__f0, short __f1 ) {
  643.     return ( (__f0.f) < (__f1<<FRACTION) );
  644. }
  645.  
  646. inline int operator < ( long __f1 , fixed const &__f0 ) {
  647.     return ( __f1 < __f0.f  );
  648. }
  649.  
  650. inline int operator < ( int __f1 , fixed const &__f0 ) {
  651.     return ( (__f1<<FRACTION) < (__f0.f) );
  652. }
  653.  
  654. inline int operator < ( short __f1 , fixed const &__f0 ) {
  655.     return ( (__f1<<FRACTION) < (__f0.f) );
  656. }
  657.  
  658. //****************************************************************************
  659. //
  660. //    >
  661. //
  662. //****************************************************************************
  663.  
  664. inline int operator > ( fixed const &__f0, fixed const &__f1 ) {
  665.     return ( __f0.f > __f1.f );
  666. }
  667.  
  668. inline int operator > ( fixed const &__f0, long __f1 ) {
  669.     return ( __f0.f > __f1 );
  670. }
  671.  
  672. inline int operator > ( fixed const &__f0, int __f1 ) {
  673.     return ( (__f0.f) > (__f1<<FRACTION) );
  674. }
  675.  
  676. inline int operator > ( fixed const &__f0, short __f1 ) {
  677.     return ( (__f0.f) > (__f1<<FRACTION) );
  678. }
  679.  
  680. inline int operator > ( long __f1 , fixed const &__f0 ) {
  681.     return ( __f1 > __f0.f );
  682. }
  683.  
  684. inline int operator > ( int __f1 , fixed const &__f0 ) {
  685.     return ( (__f1<<FRACTION) > (__f0.f) );
  686. }
  687.  
  688. inline int operator > ( short __f1 , fixed const &__f0 ) {
  689.     return ( (__f1<<FRACTION) > (__f0.f) );
  690. }
  691.  
  692. //****************************************************************************
  693. //
  694. //    <=
  695. //
  696. //****************************************************************************
  697.  
  698. inline int operator <= ( fixed const &__f0, fixed const &__f1 ) {
  699.     return ( __f0.f <= __f1.f );
  700. }
  701.  
  702. inline int operator <= ( fixed const &__f0, long __f1 ) {
  703.     return ( __f0.f <= __f1 );
  704. }
  705.  
  706. inline int operator <= ( fixed const &__f0, int __f1 ) {
  707.     return ( (__f0.f) <= (__f1<<FRACTION) );
  708. }
  709.  
  710. inline int operator <= ( fixed const &__f0, short __f1 ) {
  711.     return ( (__f0.f) <= (__f1<<FRACTION) );
  712. }
  713.  
  714. inline int operator <= ( int __f1 , fixed const &__f0 ) {
  715.     return ( (__f1<<FRACTION) <= (__f0.f) );
  716. }
  717.  
  718. inline int operator <= ( short __f1 , fixed const &__f0 ) {
  719.     return ( (__f1<<FRACTION) <= (__f0.f) );
  720. }
  721.  
  722.  
  723. //****************************************************************************
  724. //
  725. //    >=
  726. //
  727. //****************************************************************************
  728.  
  729. inline int operator >= ( fixed const &__f0, fixed const &__f1 ) {
  730.     return ( __f0.f >= __f1.f );
  731. }
  732.  
  733. inline int operator >= ( fixed const &__f0, long __f1 ) {
  734.     return ( __f0.f >= __f1 );
  735. }
  736.  
  737. inline int operator >= ( fixed const &__f0, int __f1 ) {
  738.     return ( (__f0.f) >= (__f1<<FRACTION) );
  739. }
  740.  
  741. inline int operator >= ( fixed const &__f0, short __f1 ) {
  742.     return ( (__f0.f) >= (__f1<<FRACTION) );
  743. }
  744.  
  745. inline int operator >= ( int __f1 , fixed const &__f0 ) {
  746.     return ( (__f1<<FRACTION) >= (__f0.f) );
  747. }
  748.  
  749. inline int operator >= ( short __f1 , fixed const &__f0 ) {
  750.     return ( (__f1<<FRACTION) >= (__f0.f)  );
  751. }
  752.  
  753.  
  754.  
  755.  
  756.  
  757. #if    0
  758.  
  759. inline Complex conj( Complex const &__cv ) {
  760.     return Complex( __cv.real(), -__cv.imag() );
  761. }
  762.  
  763. inline double Complex::real() const {
  764.     return( __r );
  765. }
  766.  
  767. inline double real( Complex const &__cv ) {
  768.     return( __cv.real() );
  769. }
  770.  
  771. inline double norm( Complex const &__cv ) {
  772.         return( __cv.real() * __cv.real() + __cv.imag() * __cv.imag() );
  773. }
  774.  
  775. double  abs  ( Complex const & );        // magnitude of vector
  776. Complex acos ( Complex const & );        // arccosine
  777. Complex acosh( Complex const & );        // hyperbolic arccosine
  778. double  arg  ( Complex const & );        // angle of vector
  779. Complex asin ( Complex const & );        // arcsin
  780. Complex asinh( Complex const & );        // hyperbolic arcsin
  781. Complex atan ( Complex const & );        // arctangent
  782. Complex atanh( Complex const & );        // hyperbolic arctangent
  783. Complex conj ( Complex const & );        // conjugate
  784. Complex cos  ( Complex const & );        // cosine
  785. Complex cosh ( Complex const & );        // hyperbolic cosine
  786. Complex exp  ( Complex const & );        // e raised to a power
  787. double  imag ( Complex const & );        // imaginary part
  788. Complex log  ( Complex const & );        // log base e
  789. Complex log10( Complex const & );        // log base 10
  790. double  norm ( Complex const & );        // square of magnitude
  791. Complex polar( double __mag,
  792.                  double __angle = 0 );        // polar to Complex
  793. Complex pow  ( Complex const &__base,        // Complex ** Complex
  794.                  Complex const &__power );
  795. Complex pow  ( Complex const &__base,        // Complex ** double
  796.                  double         __power );
  797. Complex pow  ( double          __base,        // double ** Complex
  798.                  Complex const &__power );
  799. Complex pow  ( Complex const &__base,        // Complex ** int
  800.                  int            __power );
  801. double  real ( Complex const & );        // real part
  802. Complex sin  ( Complex const & );        // sin
  803. Complex sinh ( Complex const & );        // hyperbolic sin
  804. Complex sqrt ( Complex const & );        // square root
  805. Complex tan  ( Complex const & );        // tan
  806. Complex tanh ( Complex const & );        // hyperbolic tangent
  807.  
  808. #endif
  809.  
  810.